﻿using GLDotNet;
using GLDotNet.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WinFormsDemo
{
    public partial class MainForm : Form
    {
        public MainForm()
        {            
            GLControl.ContextParams = new GLContextParams() { VersionMajor = 3, VersionMinor = 3, ForwardCompatible = true };

            InitializeComponent();

            this.Text = "GLDotNet WinForms - " + (Environment.Is64BitProcess ? "x64" : "x86");

            this.glControl1.ContextCreated += this.GLControl1_ContextCreated;
            this.glControl1.Render += this.GLControl1_Render;

            this.glControl2.ContextCreated += this.GLControl2_ContextCreated;
            this.glControl2.Render += this.GLControl2_Render;
        }

        private void GLControl1_ContextCreated(object sender, GLContextEventArgs e)
        {
            e.Context.ClearColor(Color4.Red);
        }

        private void GLControl1_Render(object sender, GLContextEventArgs e)
        {
            e.Context.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
        }

        private void GLControl2_ContextCreated(object sender, GLContextEventArgs e)
        {
            e.Context.ClearColor(Color4.Blue);
        }

        private void GLControl2_Render(object sender, GLContextEventArgs e)
        {
            e.Context.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
        }
    }
}
